#include<iostream>
using namespace std;

int n, x, a[100005], ans1, ans2;
signed main()
{
	cin >> n;
	int k = n;
	while (k > 0 && cin >> x)
	{
		if (cin.get() == '\n')
		{
			k--;
		}
		a[x]++;
	}
	for (int i = 1; i <= 10004; i++) {
		if (a[i - 1] && a[i + 1] && !a[i])ans1 = i;
		if (a[i] > 1)ans2 = i;
		if (ans1 && ans2)break;
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}